package day0108;

public class Teacher {
	// private 私有属性  只允许当前类访问
	private int id;
	private String name;
	private int age;
	private double salary;



	public void teach() {
		System.out.println("id是" + id + "的" + name + "正在教学");
	}
	
	public void setId( int id) {
		//就近原则，如果不加this，这两个id都是传过来的id   也就是id = id
		//this 代表当前Teacher对象的id
		this.id = id;
	}
	
	public int getId() {
		return id;
	}


	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		//可以在此控制输入的条件
		if (age >=0 && age <= 120) {  
			this.age = age;
		}
		
	}

	public double getSalary() {
		return salary;
	}

	public void setSalary(double salary) {
		this.salary = salary;
	}

	@Override
	public String toString() {
		return "Teacher [id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + "]";
	}
	
	
}